<?php
class Page extends DatabaseObject {
  function __construct($name) {
    parent::__construct('pages','id',"name LIKE '$name'");
    $this->has_many('revisions','page_id');
    $this->has_many('comments','page_id');
  }
  // skin helpers
  function content() {
    return $this->current_revision()->body;
  }
  function revision_time() {
    return $this->current_revision()->time;
  }
  function revision_author() {
    return $this->current_revision()->author;
  }
  function current_revision() {
    return $this->revisions[$this->current_revision_number()-1];
  }
  function current_revision_number() {
    return count($this->revisions);
  }
  function total_revisions() {
    return count($this->revisions);
  }
}
?>